import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;


public class Player {
	int playerWidth, playerHeight;
	double halfWidth, halfHeight;
	private Rectangle bb;
	Point2D.Double ctr,vel;
	Point roundCenter;
	private boolean isAlive;
	
	public Player(Point2D.Double startCenter, int playerWidth, int playerHeight, Point2D.Double vel){

		//Make sure to clone, we dont want the references, we just want the data.
		ctr = (Double) startCenter.clone();
		this.playerWidth = playerWidth;
		this.playerHeight = playerHeight;
		this.halfWidth = playerWidth/2.0;
		this.halfHeight = playerHeight/2.0;
		this.vel = (Double) vel.clone();
		
		bb = new Rectangle(
				(int)Math.round(ctr.x - playerWidth/2.0),
				(int)Math.round(ctr.y - playerHeight/2.0),
				playerWidth, playerHeight	);
		isAlive = true;
		roundCenter = new Point(0,0);
	}

	//For future work, maybe don't update the position of bb every frame but rather
	//only when we require checking collisions with tiles.
	public void moveCenterTo(double px, double py){				
		ctr.x = px;
		ctr.y = py;
		
		//Update player rect every time
		bb.setLocation((int)Math.round( ctr.x - halfWidth), (int)Math.round( ctr.y- halfHeight));
	}
	
	public Point getRoundedCenter(){
		roundCenter.x = (int)ctr.x;
		roundCenter.y = (int)ctr.y;
		return roundCenter;
	}
	
	public Rectangle getRect(){
		return bb;
	}
	public void setAlive(boolean isAlive){
		this.isAlive = isAlive;
	}
	public boolean isAlive(){
		return isAlive;
	}
}
